export default {
    //第一个参数就是state
    vxnum(state) {
        return state.num * state.num;
    },
    totalprice(state) {
        return state.cartlist.reduce((s, n) => s + n.price, 0);
    },
    goodsgt(state) {
        return state.cartlist.filter(n => n.price > 10);
    },
    //想复用其它计算属性
    goodsgt10Totalprice(state, getters) {
        return getters.goodsgt.reduce((s, n) => s + n.price, 0);
    },
    //想带参数
    goodsgtWithParam(state, getters) {
        /*return function (price) {
            return state.cartlist.filter(n => n.price > price);
        }*/
        return price => state.cartlist.filter(n => n.price > price);
    },
};
